package com.example.martian.controller;

import com.example.martian.service.MartianOrePoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.math.BigDecimal;
import java.text.ParseException;

@Controller
@RequestMapping("/MartianOrePool/")
@CrossOrigin
public class MartianOrePoolController {

    @Autowired
    private MartianOrePoolService martianOrePoolService;

    @RequestMapping(value = "selectMillAll")
    @ResponseBody
    public Object selectMillAll(Integer goodsType) throws ParseException {
        return martianOrePoolService.selectMillAll(goodsType);
    }


    //订单查询
    @RequestMapping(value = "selectOrderByAddress")
    @ResponseBody
    public Object selectOrderByAddress(String address,Integer type){
        return martianOrePoolService.selectOrderByAddress(address,type);
    }


    //btc计算器
    @RequestMapping(value = "calculator")
    @ResponseBody
    public Object calculator(String coin, BigDecimal price, BigDecimal number, BigDecimal hashrate,
                             BigDecimal energy, BigDecimal power, int type) throws ParseException {
        return martianOrePoolService.calculator(coin, price, number, hashrate, energy, power, type);
    }

    //eth计算器
    @RequestMapping(value = "ethCalculator")
    @ResponseBody
    public Object ethCalculator(String coin, BigDecimal price, BigDecimal number, BigDecimal hashrate,
                             BigDecimal energy, BigDecimal power, int type) throws ParseException {
        return martianOrePoolService.ethCalculator(coin, price, number, hashrate, energy, power, type);
    }

    @RequestMapping(value = "selectMillAllByHost")
    @ResponseBody
    public Object selectMillAllByHost() throws ParseException {
        return martianOrePoolService.selectMillAllByHost();
    }

    @RequestMapping(value = "selectMillAllById")
    @ResponseBody
    public Object selectMillAllById(Integer productId) throws ParseException {
        return martianOrePoolService.selectMillAllById(productId);
    }

    //矿机支付
    @RequestMapping(value = "payment")
    @ResponseBody
    public Object payment(BigDecimal money, int type, Integer jypassword, String address, String addressKey,String toAddressKey,
                          Integer productId, Integer number, String backNumber, String backName, String name, MultipartFile file) {

        return martianOrePoolService.payment(money, type, jypassword, address, addressKey,toAddressKey, productId, number, backNumber, backName, name,file);
    }

    //云算力支付
    @RequestMapping(value = "cloudPayment")
    @ResponseBody
    public Object cloudPayment(BigDecimal money, int type, Integer jypassword, String address, String addressKey,String toAddressKey,
                          Integer productId, Integer number, String backNumber, String backName, String name, MultipartFile file) {

        return martianOrePoolService.cloudPayment(money, type, jypassword, address, addressKey,toAddressKey, productId, number, backNumber, backName, name,file);
    }

    @RequestMapping(value = "selectCloudHashrate")
    @ResponseBody
    public Object selectCloudHashrate(Integer goodsType,Integer typeMill) throws ParseException {
        return martianOrePoolService.selectCloudHashrate(goodsType, typeMill);
    }

    @RequestMapping(value = "selectUnitedMining")
    @ResponseBody
    public Object selectUnitedMining(Integer goodsType,Integer typeMill) {
        return martianOrePoolService.selectUnitedMining(goodsType, typeMill);
    }

    @RequestMapping(value = "selectPrifecture")
    @ResponseBody
    public Object selectPrifecture() {
        return martianOrePoolService.selectPrifecture();
    }

    @RequestMapping(value = "selectMinerals")
    @ResponseBody
    public Object selectMinerals() {
        return martianOrePoolService.selectMinerals();
    }

    @RequestMapping(value = "millOrderPage")
    @ResponseBody
    public Object millOrderPage(Integer orderId,BigDecimal day,BigDecimal number) {
        return martianOrePoolService.millOrderPage(orderId, day, number);
    }

    @RequestMapping(value = "hashrateOrderPage")
    @ResponseBody
    public Object hashrateOrderPage(Integer orderId,BigDecimal number) {
        return martianOrePoolService.hashrateOrderPage(orderId,number);
    }

    @RequestMapping(value = "selectMillConfig")
    @ResponseBody
    public Object selectMillConfig(Integer productId) {
        return martianOrePoolService.selectMillConfig(productId);
    }

}
